<template>
  <div>
    <!--表格渲染-->
    <el-table v-loading="loading" :data="data" size="small" style="width: 100%;">
      <!-- <el-table-column prop="module" label="接口" />
      <el-table-column prop="params" label="参数" /> -->
      <el-table-column prop="remoteaddr" label="ip地址" />
      <el-table-column prop="createTime" label="登录时间">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center">
        <template slot-scope="scope">
          <div v-for="item in flags" :key="item.value">
            <templte v-if="scope.row.flag.toString() === item.value">{{ item.label }}</templte>
          </div>
        </template>
      </el-table-column>
      <el-table-column :show-overflow-tooltip="true" prop="remark" label="异常信息" />
    </el-table>
    <!--分页组件-->
    <el-pagination
      :total="total"
      :current-page="page"
      style="margin-top: 8px;"
      layout="total, sizes, prev, pager, next, jumper"
      @size-change="sizeChange"
      @current-change="pageChange"
    />
  </div>
</template>

<script>
import initData from '@/mixins/initData'
import { parseTime } from '@/utils/index'
export default {
  mixins: [initData],
  data() {
    return {
      flags: [{
        value: '0',
        label: '成功'
      }, {
        value: '1',
        label: '失败'
      }]
    }
  },
  created() {
    this.$nextTick(() => {
      this.init()
    })
  },
  methods: {
    parseTime,
    beforeInit() {
      this.url = 'system/users/logs'
      this.params = { page: this.page, size: this.size }
      return true
    }
  }
}
</script>

<style scoped>

</style>
